<template>
  <view class="teacher_homepage">
    <view class="bg_avator">
      <img :src="detail.background" alt="" />
    </view>
    <view class="content">
      <view class="box">
        <img class="avator" :src="detail.avatar" alt="" />
        <view class="name">{{ detail.name }}</view>
        <view class="rate">陪伴师星级和评分 <u-rate :disabled="true" active-color="#FF6F00" v-model="detail.star_level"></u-rate></view>

        <view class="title">基本信息</view>
        <view class="info pb24">
          <image class="info_icon" src="/static/images/info_icon_1.png" mode=""></image>
          擅长领域：{{ detail.intro }}
        </view>
        <view class="info pb24">
          <image class="info_icon" src="/static/images/info_icon_2.png" mode=""></image>
          入驻时间：2023-09-10
        </view>
        <view class="info pb24">
          <image class="info_icon" src="/static/images/info_icon_3.png" mode=""></image>
          联系方式：{{ detail.phone }}
        </view>
        <view class="info">
          <image class="info_icon" src="/static/images/info_icon_4.png" mode=""></image>
          位置：{{ detail.address }}
          <!-- 3km -->
        </view>
      </view>

      <view class="box">
        <view class="title">工作经历</view>
        <view class="info pb24">
          <image class="info_icon" src="/static/images/info_icon_5.png" mode=""></image>
          累计上课时长：{{ detail.hours }}小时
        </view>
        <view class="info">
          <image class="info_icon" src="/static/images/info_icon_6.png" mode=""></image>
          已服务小区数：5个小区
        </view>
      </view>

      <view class="box">
        <view class="title">课程安排</view>
        <view class="info pb24">
          <image class="info_icon" src="/static/images/info_icon_7.png" mode=""></image>
          日期范围：2024-08-09 至 2024-08-10
        </view>
        <view class="info pb24">
          <image class="info_icon" src="/static/images/info_icon_8.png" mode=""></image>
          包含星期：周一、周三、周五
        </view>
        <view class="info">
          <image class="info_icon" src="/static/images/info_icon_9.png" mode=""></image>
          包含时间段：08:00 ~ 09:00
        </view>
      </view>

     <!-- <view class="action">
        <view class="action_btn" @click="viewSchedule">查看详细课程安排</view>
      </view> -->
    </view>
  </view>
</template>

<script>
import { getTeacherDetail } from '@/api/class_share';
export default {
  data() {
    return {
      rating: 4,
      eventId: '',
      detail: {},
    };
  },
  methods: {
    viewSchedule() {
      uni.navigateTo({
        url: `/pages/class/index?id=${this.eventId}`,
      });
    },
  },
  onLoad(options) {
    this.eventId = options.id;
    getTeacherDetail({ id: this.eventId } || 1)
      .then(res => {
        this.detail = res;
        console.log(res);
      })
      .catch(error => {
        console.error('请求失败:', error);
      });
  },
};
</script>

<style lang="scss" scoped>
.teacher_homepage {
  background: #f7f7f7;
  .bg_avator {
    width: 100%;
    height: 573rpx;
    border-bottom-left-radius: 40%;
    border-bottom-right-radius: 40%;
    opacity: 0.4;
  }
  .content {
    margin: 0 24rpx;
    transform: translateY(-120rpx);
    position: relative;
    .box {
      background: #fff;
      border-radius: 20rpx;
      padding: 32rpx 24rpx;
      margin-bottom: 24rpx;
      position: relative;
      .title {
        font-family: PingFangSC, PingFang SC;
        font-weight: 500;
        font-size: 32rpx;
        color: #000000;
        line-height: 32rpx;
        font-style: normal;
        padding-bottom: 32rpx;
      }
      .info {
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: 26rpx;
        color: #666666;
        font-style: normal;
        .info_icon {
          width: 20rpx;
          height: 20rpx;
          margin-right: 24rpx;
        }
      }
      .pb24 {
        padding-bottom: 24rpx;
      }

      .avator {
        width: 150rpx;
        height: 150rpx;
        border-radius: 50%;
        position: absolute;
        left: 40%;
        top: -18%;
      }
      .name {
        font-family: PingFangSC, PingFang SC;
        font-weight: 500;
        font-size: 32rpx;
        color: #010101;
        line-height: 32rpx;
        text-align: center;
        font-style: normal;
        padding-top: 42rpx;
      }
      .rate {
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: 24rpx;
        color: #666666;
        line-height: 24rpx;
        text-align: center;
        font-style: normal;
        margin: 30rpx 0 66rpx 0;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }
  }
  .action {
    margin: 100rpx 8rpx 20rpx 8rpx;

    .action_btn {
      height: 90rpx;
      background: #0dc160;
      border-radius: 44rpx;
      line-height: 90rpx;

      font-family: PingFangSC, PingFang SC;
      font-weight: 500;
      font-size: 30rpx;
      color: #ffffff;
      text-align: center;
      font-style: normal;
    }
  }
}
</style>
